package org.spring.core.io;

import java.net.MalformedURLException;

/**
 * DefaultResourceLoader
 *
 * @author 李坤
 * @date 2022/4/16 10:33
 */
public class DefaultResourceLoader implements ResourceLoader {

    @Override
    public Resource getResource(String location) {
        if (location.startsWith(ClassPathResource.ClassPathUtil.CLASSPATH_URL_PREFIX)) {
            return new ClassPathResource(location);
        } else {
            try {
                return new UrlResource(location);
            } catch (MalformedURLException exception) {
                return new FileSystemResource(location);
            }
        }
    }

}
